package com.wl.employee.util;

import java.sql.*;

public class DBUtil {
    private static final String URL = "jdbc:oracle:thin:@localhost:1521:orcl";
    private static final String USER = "scott";
    private static final String PASSWORD = "tiger";

    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        // 1.加载驱动程序
        Class.forName("oracle.jdbc.driver.OracleDriver");
        // 2.获得数据库连接
        Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
        // 3.通过数据库的连接操作数据库实现增删改查
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT id, ename, sex, birthday, join_Date, eno from employee");
        while (rs.next()) {
            System.out.println(rs.getInt("id") + "," + rs.getString("ename") + "," + rs.getInt("sex") + "," +
                    rs.getDate("birthday") + "," + rs.getDate("join_date") + "," + rs.getString("eno") );
        }

    }

}